<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;list-style: none;}
        #box{
            width: 400px;
            padding: 30px;
            background-color: #61a1bc;
            margin: 50px auto;
        }
        h1{
            font-size: 40px;
            text-align: center;
        }
        ul{
            padding: 10px 0;
            border-bottom: 1px solid gainsboro;
        }
        li{
            background-color: #e0c921;
            margin: 10px 0;
            line-height: 50px;
            text-align: left;
            padding: 0 20px;
            font-size: 24px;
        }
        li span{
            float: right;
        }
        .tal{
            font-size: 24px;
            padding-top: 10px;
        }
        .tal span{
            float: right;
        }
        .active{
            background-color: #8dc16e;
        }
    </style>
</head>
<body>
    <div id="box">
        <h1>Services</h1>
        <ul>
            <li v-for="(item,index) in arr" @click="fn(item)" :class="{active:item.has}">
                {{item.name}}
                <span>{{item.price}}</span>
            </li>
        </ul>
        <div class="tal">
            Total: <span>{{num()}}</span>
        </div>
    </div>
</body>
<script src="js/vue.js"></script>
<script>
    let vm = new Vue({
        el:"#box",
        data:{
            arr:[
                {name:"Web Development",price:3000,has:false},
                {name:"Python",price:1000,has:false},
                {name:"Java",price:2000,has:false},
                {name:"GO",price:2200,has:false},
            ]
        },
        methods:{
            fn(item){
                item.has = !item.has
            },
            num(){
                let num = 0
                this.arr.forEach(v=>{
                    if(v.has){
                        num += v.price
                    }
                })
                console.log(num);
                return num
            }
        }
    })
</script>
</html>